package ttt;

import org.junit.Before;
import org.junit.Test;

//import junit.framework.TestCase;
//import junit.framework.Test;
import static org.junit.Assert.*;
//import junit.framework.TestSuite;

public class TicTacToeTest{
	TicTacToe tttg;
	@Before
	public void init(){
		tttg = new TicTacToe();
	}
	
	@Test
	public void testPosition(){
		//check positionValue
		//positionValue checks if there is a winner or draw or nothing yet (UNCLEAR).
		tttg.setHumanPlays();
		tttg.playMove(1);
		//System.out.println(tttg.positionValue());
		assertNotSame(tttg.COMPUTER_WIN, tttg.positionValue());
		assertNotSame(tttg.HUMAN_WIN, tttg.positionValue());
		assertNotSame(tttg.DRAW, tttg.positionValue());
		assertEquals(tttg.UNCLEAR,tttg.positionValue());
		
	}
	@Test
	public void testWin(){
		tttg.setHumanPlays();
		tttg.playMove(0);
		assertFalse(tttg.isAWin(tttg.HUMAN));
		tttg.setHumanPlays();
		tttg.playMove(1);
		tttg.setHumanPlays();
		tttg.playMove(2);
		assertTrue(tttg.isAWin(tttg.HUMAN));
		
	}
	@Test
	public void testChooseMove(){
		 tttg.setComputerPlays();
        // assertEquals(1,tttg.chooseMove());
        // while(!(tttg.gameOver() && tttg.boardIsFull())){
        //	 tttg.playMove(tttg.chooseMove());
        //	 System.out.println(tttg.toString());
         //}
		 System.out.println(tttg.toString());
		//tttg.setComputerPlays();
		tttg.playMove(tttg.chooseMove());
		 tttg.setComputerPlays();
		System.out.println(tttg.toString());
		 tttg.setComputerPlays();
		tttg.playMove(tttg.chooseMove());
		System.out.println(tttg.toString());
		 tttg.setComputerPlays();
		tttg.playMove(tttg.chooseMove());
		System.out.println(tttg.toString());
		//tttg.playMove(tttg.chooseMove());
		//System.out.println(tttg.toString());
         //tttg.playMove(tttg.chooseMove());
         //tttg.playMove(8);
         assertEquals(tttg.COMPUTER_WIN,tttg.positionValue());
	}
	/*public static Test suite() {
		TestSuite suite = new TestSuite("Test for test");
		//$JUnit-BEGIN$
		//$JUnit-END$
		return suite;
	}*/

}
